<?php
//绝对系统目录
define('BASEDIR', dirname(__FILE__));//当前目录 等于core
define('CORDIR', dirname(__FILE__));//当前目录 core
define('SYSDIR', dirname(BASEDIR));
define('CLASSDIR', SYSDIR . '/class');
define('CONFIGDIR', SYSDIR . '/config');
define('PUBLICDIR', dirname(SYSDIR) . '/public');

//网站目录
define('DOMAIN', 'http://my-todo-easy');
define('STYLESHEETSDIR', DOMAIN . '/assets/stylesheets');
define('JAVASCRIPTDIR', DOMAIN . '/assets/javascript');
//包含目录
set_include_path(PUBLICDIR . "/inc");


//数据库配置文件
include_once CONFIGDIR . '/db-cred.php';
foreach ($C as $key => $value) {
    define($key, $value);
}

//链接mysql
$dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME;
//try {
    $dbo = new PDO($dsn, DB_USER, DB_PASS);
//} catch (PDOException $e) {
//    echo 'Connection failed: ' . $e->getMessage();
//}

//自动加载类
function __autoload($className) {
    $filename = CLASSDIR . '/' . $className . '.php';
    if (file_exists($filename)) {
        include_once ($filename);
    } else {
        exit('no calss file');
    }
}

?>